import ManyFood.*;
import javax.xml.stream.events.EndDocument;
import javax.xml.parsers.*;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import java.io.File;

public class Main {
    public static void main(String[] args) {
        try {
            //实例化XML调用
            ReadClassNameFromXML avaliableXML = new ReadClassNameFromXML();
            String nowFilePath="src//config.xml";
            //抽象Class通过参数得到具体的是哪个工厂
            Class clssFactory = Class.forName(avaliableXML.getClassName(nowFilePath));
            Object objectFactory = clssFactory.newInstance();
            IFoodFactory factory;
            factory = (IFoodFactory) objectFactory;

            Food testFood = factory.foodFactoryMethod("火锅，麻辣火锅~");
            System.out.println(testFood.showInfo());

            Food testFood2 = factory.foodFactoryMethod();
            System.out.println(testFood2.showInfo());
        }
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
        finally {
            System.out.println("结束");
        }
    }
}
